/*
 * Copyright (c) 2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "cert_utils_openssl.h"

#include "securec.h"

#include <openssl/bio.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
#include <openssl/pkcs7.h>
#include <openssl/rsa.h>
#include <openssl/x509.h>

#include "config.h"
#include "fwk_class.h"
#include "cf_log.h"
#include "cf_memory.h"
#include "certificate_openssl_class.h"
#include "certificate_openssl_common.h"
#include "utils.h"


static CfResult GetGeneralName(HcfCertUtilsSpi *self, int32_t type, const char *data, CfBlob *out)
{
    return CF_SUCCESS;
}

static CfResult CompareBigNum(HcfCertUtilsSpi *self, CfBlob *lhs, CfBlob *rhs, bool *out)
{
    return CF_SUCCESS;
}

CfResult OpensslCertUtilsSpiCreate(HcfCertUtilsSpi **spi)
{
    if (spi == NULL) {
        LOGE("Invalid Paramas!");
        return CF_INVALID_PARAMS;
    }
    HcfCertUtilsSpi *ret = (HcfCertUtilsSpi *)HcfMalloc(sizeof(HcfCertUtilsSpi), 0);
    if (ret == NULL) {
        LOGE("Failed to malloc for x509 instance!");
        return CF_ERR_MALLOC;
    }
    ret->engineGetGeneralName = GetGeneralName;
    ret->engineCompareBigNum = CompareBigNum;

    *spi = ret;
    return CF_SUCCESS;
}
